package com.yanqu.road.server.cmd.activity;

import com.yanqu.road.entity.activity.ActivityRewardResult;
import com.yanqu.road.pb.activity.ActivityProto;
import com.yanqu.road.pb.crossunion.activity.CrossUnionActivityRankDataProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.ActivityModule;
import com.yanqu.road.server.pb.ActivityPb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = GameProtocol.S_SYNC_CROSS_UNION_RANK_REWARD,desc = "")
public class GetActivityUnionRewardCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        CrossUnionActivityRankDataProto.CrossUnionRankRewardRespMsg req = CrossUnionActivityRankDataProto.CrossUnionRankRewardRespMsg.parseFrom(packet.getBytes());
        int activityId = req.getActivityId();
        int position = req.getPosition();
        int myRank = req.getMyRank();
        ActivityRewardResult rewardResult = player.getModule(ActivityModule.class).getUnionRankActivityRewardFromCross(activityId,myRank,position);
        rewardResult.setActivityId(activityId);
        ActivityProto.ActivityGetRewardRespMsg.Builder respMsg = ActivityPb.parseActivityGetRewardRespMsg(rewardResult);
        if(null != respMsg) {
            player.sendPacket(Protocol.U_ACTIVITY_GET_REWARD, respMsg);
        }
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
